package com.parkreport.base;

import java.io.IOException;
import java.io.OutputStream;

import com.common.doc.xsl.POIFManager;
import com.common.report.vo.ReportTableViewVO;

public class ReportAction extends BaseAction {

	private String tableVoName="tableVO";
	public void expXls() {
		OutputStream output = null;
		try {
			output = this.getResponse().getOutputStream();
			byte b[] = new byte[1024];
			ReportTableViewVO viewVO = (ReportTableViewVO) this.getRequest().getSession()
					.getAttribute(tableVoName);
			POIFManager _poif = POIFManager.createCell4T();
			_poif.iteratorValue4XLS(viewVO);
			String docName = viewVO.getReportName() + ".xls";
			docName = java.net.URLEncoder.encode(docName, "UTF-8");
			this.getResponse().setHeader("Content-Disposition", "attachment;filename="
					+ new String(docName.getBytes("UTF-8"), "gb2312"));
			this.getResponse().setContentType("application/vnd.ms-excel;charset=gb2312");
			_poif.writ2OutStream(output);
		} catch (Exception e) {
			log.error(e.getMessage(),e);
		} finally {
			try {
				output.close();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}

	}
	
	public void expMutilXls() {
		OutputStream output = null;
		try {
			output = this.getResponse().getOutputStream();
			byte b[] = new byte[1024];
			ReportTableViewVO viewVO = (ReportTableViewVO) this.getRequest().getSession()
					.getAttribute(tableVoName);
			POIFManager _poif = POIFManager.createCell4T();
			_poif.iteratorMutilValue4XLS(viewVO);
			String docName = viewVO.getReportName() + ".xls";
			docName = java.net.URLEncoder.encode(docName, "UTF-8");
			this.getResponse().setHeader("Content-Disposition", "attachment;filename="
					+ new String(docName.getBytes("UTF-8"), "gb2312"));
			this.getResponse().setContentType("application/vnd.ms-excel;charset=gb2312");
			_poif.writ2OutStream(output);
		} catch (Exception e) {
			log.error(e.getMessage(),e);
		} finally {
			try {
				output.close();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}

	}
	public String getTableVoName() {
		return tableVoName;
	}
	public void setTableVoName(String tableVoName) {
		this.tableVoName = tableVoName;
	}
}
